
// 引用vue，安装路由功能
import Vue from 'vue'
import VueRouter from 'vue-router'

import Home from '../views/Home.vue'
import User from '../views/User.vue'
import Main from '../views/Main.vue'
import Mall from '../views/Mall.vue'
import PageOne from '@/views/PageOne.vue'
import PageTwo from '@/views/PageTwo.vue'
// import { component } from 'vue/types/umd'

Vue.use(VueRouter)
// 1,创建路由组件
// 2，制定路由规则
// 3. 创建 router 实例，然后传 `routes` 配置
const routes = [
    {
        path: '/',
        component: Main,
        redirect: '/home',
        children: [
            // 子路由
            { path: '/home', name: 'home', component: Home },//首页
            { path: '/user', name: 'user', component: User },//用户管理
            { path: '/mall', name: 'mall', component: Mall },//商品管理
            { path: '/page1', name: 'page1', component: PageOne },//首页
            { path: '/page2', name: 'page2', component: PageTwo },//用户管理
        ]

    },
    // { path: '/home', component: Home },
    // { path: '/user', component: User }
]
const router = new VueRouter({
    // mode: 'history',
    routes // (缩写) 相当于 routes: routes
})
export default router
